*	Topic: LAB3 Pt. 11
*	Submitted by : Vishal Verma
*	Date: 2/21/2011
*	Program To test serial port operation and XRAM memory map while blinking an LED
*	ECEN5613 S2011




			ORG $2000				* 	RESET VECTOR	
			LJMP MYCODE				* 	JUMP TO MAIN CODE
			
			ORG $2100				*	MAIN PROGRAM
MYCODE:
			MOV R4,#0AH				*	SET COUNTER FOR VALUE OF 0AH
			MOV IE,#%00000010		*	DISABLE GLOBAL INTERRUT EA=0   ENABLE TIMER INTERRUPT ET0 =1
			MOV IP,#%00000010		* 	TIMER 0 SET TO HIGHEST PRIORITY INTERRUPT
			MOV PSW,#%00000000		*	SELECT REGISTER BANK 0
			MOV TMOD,#%00100001		*	TIMER 0 IN MODE 1
			MOV TCON,#%00000000		*	CLEAR TIMER FLAG TF0 = 0 CLEAR RUN FLAG TR0 =0
			MOV TH0,#4CH			* 	LOAD TIMER 0 HIGHER (LED)
			MOV TL0,#00H			* 	LOAD TIMER 0 LOWER (LED)
			SETB IE.7				*	ENABLE GLOBAL INTERRUPT   EA=1
			SETB TCON.4				*	START TIMER   TR0=1
			MOV SCON,#50H
			MOV TL1,#00H			* 	LOAD TIMER 1 HIGHER (SERIAL)
			MOV TH1,#0FDH			* 	LOAD TIMER 1 LOWER (SERIAL)
			MOV DPTR,#8000H
			SETB TCON.6		
			MOV A,#48H
			MOVX [DPTR],A
			MOVX A,[DPTR]
			CJNE A,#48H,NOTEQUAL
			MOV A,#59H
			SJMP AGAIN
NOTEQUAL:	MOV A,#4EH			
AGAIN:		MOV SBUF,A
HERE:		JNB SCON.1,HERE
			CLR SCON.1
			SJMP AGAIN


			
			ORG $200B				*	TIMER 0 VECTOR
			SETB P1.0				*	SET SECOND PORT PIN I.E SET PORT PIN1.0
			LJMP MYISR				*	JUMP TO TIMER ISR
			
			
			ORG $2200				*	TIMER ISR
MYISR:		CLR IE.7				*	DISABLE INTERRUPT
			DJNZ R4,NOTDONE			*	SEE IF R4 IS NOT ZERO
			
			MOV R4,#0AH				*	RELOAD VALUE OF COUNTER
			CPL P1.7				*	COMPLEMENT FIRST PORT PIN
	
NOTDONE:	MOV TH0,#4CH			*	RELOAD TIMER
			MOV TL0,#00H			*	RELOAD TIMER
			SETB TCON.4				*	START TIMER   TR0=1
			SETB IE.7				*	ENABLE GLOBAL INTERRUPTS
			CLR P1.0				*	CLEAR SECOND PORT PIN
			RETI					*	RETURN FROM ISR